///
/// Call custom application logic when a row is selected in a table control in your application.
///
public override void ${Button Control}_Click(object sender, EventArgs args)
{
try
{
// Start Transaction
DbUtils.StartTransaction();
// Get selected record controls.
${Table Control Class}Row[] records = this.GetSelectedRecordControls();
// If there are selected Records then
if (records.Length >0)
{
// Loop through each selected record controls
foreach (${Table Control Class}Row rec in records) {
// Get the database record and do your custom business processing here.
${Table Name}Record myRec = rec.GetRecord();
// Concatenate two fields and display them in a control.
rec.${Display Control}.Text = myRec.${First Field Value}.ToString() + " " + myRec.${Second Field Value}.ToString();
}
}else
{
// Display message to prompt record selection.
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "Message", "Please select a record");
}
}
catch(Exception ex)
{
DbUtils.RollBackTransaction();
// Report the error message to the user
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPT", ex.Message);
}
finally
{
// End Transaction
DbUtils.EndTransaction();
}
}
|